package com.white.server.impl;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.Scanner;

public class ClientSend implements Runnable {

    private final Socket serverSocket;
    private ObjectOutputStream outputStream;
    public ClientSend(Socket serverSocket, ObjectOutputStream outputStream) {
        this.serverSocket = serverSocket;
        this.outputStream = outputStream;
    }

    @Override
    public void run() {
        try {
            Scanner in = new Scanner(System.in);
            while (true) {
                System.out.println("发送服务端：");
                String msg = in.nextLine();
                outputStream.writeObject(msg);
                outputStream.flush();
            }
        } catch (IOException e) {
            Client.reConnection();
            e.printStackTrace();
        }
    }
}
